package com.javatest.springboot3minio.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA. Description:
 *
 * @author liuzi
 * @since 2024/1/10 10:30
 */
@Configuration
public class MinioClientConfig {
  private MinioProperties minioProperties;

  @Autowired
  public void setMinioProperties(MinioProperties minioProperties) {
    this.minioProperties = minioProperties;
  }

  @Bean
  public MinioClient minioClient() {
    return MinioClient.builder()
        .endpoint(minioProperties.getEndpoint())
        .credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey())
        .build();
  }
}
